//
//  YouHuiQuanCell.m
//  XDBaseFrameWork
//
//  Created by xindao on 14-10-2.
//  Copyright (c) 2014年 XD-XY. All rights reserved.
//

#import "YouHuiQuanCell.h"

@implementation YouHuiQuanCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self makeViews];
    }
    return self;
}

- (void)makeViews{

    _borderBg = [UIView initViewRect:CGRectMake(10, 6, UI_SCREEN_WIDTH-20, 100) andBackGroudColor:[UIColor clearColor]];
    _borderBg.layer.borderColor = UIColorFromRGB(0xdddddd).CGColor;
    _borderBg.layer.borderWidth = .5f;
    [self.contentView addSubview:_borderBg];

    _colorBg = [UIView initViewRect:CGRectMake(.5f, .5f, 205, 99) andBackGroudColor:[UIColor orangeColor]];
    [_borderBg addSubview:_colorBg];

    _priceLB = [UILabel initLabelText:@"￥100.00" andRect:CGRectMake(10,15,195,50) andBackGroudColor:[UIColor clearColor] andTextFont:[UIFont systemFontOfSize:38] andTextColor:[UIColor whiteColor] andTextAlignment:NSTextAlignmentLeft];
    _priceLB.attributedText = [XDTools getAcolorfulStringWithTextArray:@[@"￥"] Color:[UIColor whiteColor] Font:[UIFont systemFontOfSize:23] AllText:_priceLB.text];
    [_borderBg addSubview:_priceLB];

    _nameLB = [UILabel initLabelText:@"新手注册优惠券" andRect:CGRectMake(10,73,180,16) andBackGroudColor:[UIColor clearColor] andTextFont:[UIFont systemFontOfSize:14] andTextColor:[UIColor whiteColor] andTextAlignment:NSTextAlignmentLeft];
    [_borderBg addSubview:_nameLB];

    UILabel * label = [UILabel initLabelText:@"使用期限" andRect:CGRectMake(205,10,93,16) andBackGroudColor:[UIColor clearColor] andTextFont:[UIFont systemFontOfSize:14] andTextColor:UIColorFromRGB(0x453d35) andTextAlignment:NSTextAlignmentCenter];
    [_borderBg addSubview:label];

    _beginTimeLB = [UILabel initLabelText:@"2014.09.19" andRect:CGRectMake(205,height_y(label)+4,93,16) andBackGroudColor:[UIColor clearColor] andTextFont:[UIFont systemFontOfSize:14] andTextColor:UIColorFromRGB(0x453d35) andTextAlignment:NSTextAlignmentCenter];
    [_borderBg addSubview:_beginTimeLB];

    _endTimeLB = [UILabel initLabelText:@"2014.09.29" andRect:CGRectMake(205,height_y(_beginTimeLB)+4,93,16) andBackGroudColor:[UIColor clearColor] andTextFont:[UIFont systemFontOfSize:14] andTextColor:UIColorFromRGB(0x453d35) andTextAlignment:NSTextAlignmentCenter];
    [_borderBg addSubview:_endTimeLB];

    _statusIV = [[UIImageView alloc] initWithFrame:CGRectMake(_borderBg.bounds.size.width-62.5f, _borderBg.bounds.size.height-54.5f, 62, 54)];
    [_borderBg addSubview:_statusIV];
}

- (void)initViewsWithDict:(NSDictionary *)dict{
    
    _beginTimeLB.text = dict[@"DateS"];
    _endTimeLB.text = dict[@"DateE"];
    _nameLB.text = dict[@"VoucherDesc"];
    _priceLB.text = [NSString stringWithFormat:@"￥%@",dict[@"VoucherPrice"]];
    _priceLB.attributedText = [XDTools getAcolorfulStringWithTextArray:@[@"￥"] Color:[UIColor whiteColor] Font:[UIFont systemFontOfSize:24] AllText:_priceLB.text];
    if ([dict[@"status"] intValue] == 1) {
        _colorBg.backgroundColor = RGBA(243, 80, 116, 1);
        _statusIV.hidden = NO;
        _statusIV.image = [UIImage imageNamed:@"haveused"];
    }else if ([dict[@"status"] intValue] == 2) {
        _colorBg.backgroundColor = RGBA(243, 80, 116, 1);
        _statusIV.hidden = YES;
    }else{
        _colorBg.backgroundColor = RGBA(189, 189, 189, 1);
        _statusIV.hidden = NO;
        _statusIV.image = [UIImage imageNamed:@"cantused"];
    }

}

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
